package program

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url value(consumer(regex('/api/programs/subTopics')),
                producer('/api/programs/subTopics'))
        headers {
            contentType(applicationJsonUtf8())
        }
    }
    response {
        status 200
        body("""
            [{
                "id": 1,
                "title": "program title",
                "createTime": "2016-09-09 00:00:00.0",
                "startTime": "2017-09-09 00:00:00.0",
                "endTime": "2017-09-09 00:00:00.0",
                "creatorId": 2,
                "introduction": "program introduction",
                "category": "付费",
            }]
        """)
        bodyMatchers {
            jsonPath('$.[*]',byType())
            jsonPath('$.[*].id',byRegex(number()))
            jsonPath('$.[*].title',byRegex(nonEmpty()))
            jsonPath('$.[*].createTime',byRegex(nonEmpty()))
            jsonPath('$.[*].startTime',byRegex(nonEmpty()))
            jsonPath('$.[*].endTime',byRegex(nonEmpty()))
            jsonPath('$.[*].creatorId',byRegex(number()))
            jsonPath('$.[*].introduction',byRegex(nonEmpty()))
            jsonPath('$.[*].category',byRegex(nonEmpty()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }

}